/*
    Description:    This class holds general campus information and functions.
    Author:         Carlos Krefft (krefftc@gmail.com)
*/
FIUMAPS.CampusInfo = { current_campus_id: 1, current_campus_code: "MMC",
    arrData: [{ "ID": 1,
        "Code": "MMC",
        "Name": "Modesto A. Maidique Campus",
        "ZoomLevel": 16,
        "GLatLong": new GLatLng(25.755217790, -80.373616218566)
    },
                { "ID": 2,
                    "Code": "BBC",
                    "Name": "Biscayne Bay Campus",
                    "ZoomLevel": 16,
                    "GLatLong": new GLatLng(25.909377899, -80.1364445686)
                },
                { "ID": 3,
                    "Code": "CEAS",
                    "Name": "Engineering Center",
                    "ZoomLevel": 16,
                    "GLatLong": new GLatLng(25.76866795, -80.36385297)
                },
                { "ID": 4,
                    "Code": "BPC",
                    "Name": "FIU Broward - Pines Center",
                    "ZoomLevel": 16,
                    "GLatLong": new GLatLng(26.0292139686, -80.3733372688)
                },
                { "ID": 5,
                    "Code": "MET",
                    "Name": "The Metropolitan Center",
                    "ZoomLevel": 17,
                    "GLatLong": new GLatLng(25.7729, -80.1902)
                },
                { "ID": 6,
                    "Code": "WLF",
                    "Name": "The Wolfsonian-FIU",
                    "ZoomLevel": 17,
                    "GLatLong": new GLatLng(25.7809, -80.1324)}],

    getCampusCodeFromID: function(id) {
        //if id found, return code.
        for (var z = 0; z < this.arrData.length; z++) {
            if (this.arrData[z].ID == id) {
                //return code
                return this.arrData[z].Code;
            }
        }
    },
    goToCampusByID: function(id) {
        //loop through campuses
        for (var x = 0; x < this.arrData.length; x++) {
            //if campus_id found, setCenter of map.
            if (id == this.arrData[x].ID) {
                FIUMAPS.Tabs.applyCSS(id);
                if (URLDecode(getQuerystring('zl'))) {
                    gmap.setCenter(this.arrData[x].GLatLong, parseInt(URLDecode(getQuerystring('zl'))));
                } else {
                    gmap.setCenter(this.arrData[x].GLatLong, this.arrData[x].ZoomLevel);
                }
                // set new current campus id.
                this.setCurrentCampusID(id);
            }
        }
    },
    goToCampusByCode: function(code) {
        //loop through campuses
        for (var x = 0; x < this.arrData.length; x++) {
            //if campus_id found, setCenter of map.
            if (code == this.arrData[x].Code) {
                FIUMAPS.Tabs.applyCSS(id);
                if (URLDecode(getQuerystring('zl'))) {
                    gmap.setCenter(this.arrData[x].GLatLong, parseInt(URLDecode(getQuerystring('zl'))));
                } else {
                    gmap.setCenter(this.arrData[x].GLatLong, this.arrData[x].ZoomLevel);
                }
                //                if (isNaN(gmap.getZoom())){
                //                    gmap.setCenter(this.arrData[x].GLatLong, this.arrData[x].ZoomLevel);
                //                }else{
                //                    gmap.setCenter(this.arrData[x].GLatLong, gmap.getZoom());
                //                }
                // set new current campus id.
                this.setCurrentCampusCode(code);
            }
        }
    },
    setCurrentCampusCode: function(code) {
        this.current_campus_code = code;
        for (var z = 0; z < this.arrData.length; z++) {
            if (this.arrData[z].Code == code) {
                //reset id as well.
                this.current_campus_id = this.arrData[z].ID;
            }
        }
    },
    setCurrentCampusID: function(id) {
        this.current_campus_id = id;
        for (var z = 0; z < this.arrData.length; z++) {
            if (this.arrData[z].ID == id) {
                //reset code as well.
                this.current_campus_code = this.arrData[z].Code;
            }
        }
    },
    getCurrentCampusCode: function() {
        return this.current_campus_code;
    },
    getCurrentCampusID: function() {
        return this.current_campus_id;
    }
};

